//
//  GoodsTopSelectView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "GoodsTopSelectView.h"

@implementation GoodsTopSelectView

-(id)initWithFrame:(CGRect)aFrame inSuperView:(UIView *)aSuperView{
    if (self = [super initWithFrame:aFrame inSuperView:aSuperView]) {
        self.backgroundColor = [UIColor whiteColor];
        CGFloat lineWidth = kWidthProportion_In_iPhoneTriploid(1);
        CGFloat butWidth = (KScreenWidth - lineWidth*2)/3;
        NSArray * titarr = @[@"所有地区",@"综合排序",@"筛选"];
        for (int i=0; i<3; i++) {
            GLGWButton * topBut = [[GLGWButton alloc] initWithFrame:CGRectMake(butWidth*i + lineWidth*i, 0, butWidth, self.height) titleLableFont:SYSTEMFONT(14) titleColor:[UIColor colorWithHexString:@"#333333"] inSuperView:self];
            topBut.titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
            topBut.title = titarr[i];
            if (i<2) {
                GLGWView * l_view = [[GLGWView alloc] initWithFrame:CGRectMake(kX_With_View(topBut, 0), kHeightProportion_In_iPhoneTriploid(10), kWidthProportion_In_iPhoneTriploid(1), kHeightProportion_In_iPhoneTriploid(14)) inSuperView:self];
                l_view.backgroundColor = [UIColor colorWithHexString:@"#DEDEDE"];
            }
            topBut.tag = 180+i;
            [topBut addTarget:self action:@selector(butAction:) forControlEvents:UIControlEventTouchUpInside];
        }
        GLGWView * lineView = [[GLGWView alloc] initWithFrame:CGRectMake(0, kHeightProportion_In_iPhoneTriploid(34), KScreenWidth, kHeightProportion_In_iPhoneTriploid(1)) inSuperView:self];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
    }
    return self;
}

-(void)butAction:(GLGWButton *)sender{
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectTopViewButTag:)]) {
        [self.delegate selectTopViewButTag:sender.tag];
    }
}

@end
